/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.Date;
import models.PostBO;
import myconfession.dao.PostDAO;
import myconfession.dto.post.Post;
import myconfession.utils.XMLUtility;
import org.omg.PortableInterceptor.SUCCESSFUL;

/**
 *
 * @author BAOLA
 */
public class SendConfessionAction {

    private int pageId;
    private String confess;
    private Date  date = new Date();

    public SendConfessionAction() {
    }

    public String execute() throws Exception {
        //hrow new UnsupportedOperationException("Not supported yet.");
        Post p = new Post();
        p.setPageId(new BigInteger(pageId+""));
        p.setPostContent(confess);
        p.setDate(XMLUtility.getXMLGregorianCalendarNow());
                
        p.setStatus(PostBO.UNREAD);

        boolean rs = PostBO.AddPost(p);
        if (rs) {
            return "success";
        }
        return "fail";
    }

    /**
     * @return the pageId
     */
    public int getPageId() {
        return pageId;
    }

    public String getConfess() {
        return confess;
    }

    public void setConfess(String confess) {
        this.confess = confess;
    }

    /**
     * @param pageId the pageId to set
     */
    public void setPageId(int pageId) {
        this.pageId = pageId;
    }

    /**
     * @return the date
     */
    public Date getDate() {
        return date;
    }

    /**
     * @param date the date to set
     */
    public void setDate(Date date) {
        this.date = date;
    }
}
